package leetcode.singles;

/**
 * @Author: Liu Yue
 * @Descripition:
 * @Date; Create in 2020/3/1 11:47
 **/
public class DoubleSingle {
    private volatile static DoubleSingle doubleSingle ;

    static {
        doubleSingle = new DoubleSingle();
    }
    private DoubleSingle(){}

    public   static DoubleSingle instance() {
        //第一检查是否阻塞
        if (doubleSingle == null) {
            synchronized (DoubleSingle.class) {
                //第二次检查是否创建实例
                if (doubleSingle == null) {
                    doubleSingle = new DoubleSingle();
                }
            }
        }
        return doubleSingle;
    }
}
